#@layout()
#define main()
<!-- 内容区域 -->
<div class="aw-container-wrap">
	<div class="container">
		<div class="row">
			<div class="aw-content-wrap clearfix">
				<div class="col-sm-12 col-md-8 aw-main-content aw-article-content">
					<div class="aw-mod aw-question-detail">
						<div class="mod-head">
							<h1>#(article.title)</h1>
							<span class="pull-right  more-operate">
								#if(ret.isFavoriteActive == "active")
								<a href="javascript:;" class="text-color-999 " onclick="articleFavorite('article', #(article.aid),false,this);" ><i class="icon icon-favor"></i> <b>#(ret.favoriteCount)</b> 取消收藏</a>
								#else
								<a href="javascript:;" class="text-color-999 " onclick="articleFavorite('article', #(article.aid),true,this);" ><i class="icon icon-favor"></i> <b>#(ret.favoriteCount)</b> 收藏</a>
								#end
							</span>
							<em class="text-color-999">
								分类：<a class="aw-question-tags" href="/topic/detail/#(article.typeId)">#(article.name)</a>| 作者
								<a class="aw-user-name" href="/user/detail/#(article.uid)" data-id="#(article.uid)">#(article.nickName)</a>
								| 发布于 #date(article.addtime, "yyyy-MM-dd") |
								<span id="read-time"></span>| 阅读数：
								<span>#(article.views)</span>
								<span style="color: red">
                                 #if(article.is_pay==1)所需： #(article.points) 积分
                                 #end
                                 </span>
							</em>
						</div><hr/>
						<div class="mod-body" style="margin-top: 15px;">
							<div class="content markitup-box">
								<div id="markdown_out">
									#(article.content)
								</div>
								<div class="aw-upload-img-list"></div>
								<hr />
							</div>
						</div>
						#if(article.is_pay==1)
						<div class="mod-body" style="margin-top: 15px;">
							<div style="margin: 0 auto;text-align:center;">
								<button type="button" class="btn btn-success" onclick="download(#(article.aid))" style="border-radius: 50px;width: 100px;height: 40px;">立即下载</button>
								<button type="button" class="btn btn-danger" onclick="downloadVip(#(article.aid))" style="border-radius: 50px;width: 150px;height: 40px;">VIP免积分下载</button>
							</div>
						</div>
						#end
					</div>
					#include("_articleReply.html")
				</div>
				<!-- 侧边栏 -->
				<div class="col-sm-12 col-md-3 aw-side-bar">
					<!-- 发起人 -->
					<div class="aw-mod user-detail">
						<div class="mod-head">
							<h3>发起人</h3>
						</div>
						<div class="mod-body">
							<dl>
								<dt class="pull-left aw-border-radius-5">
									<a href="/user/detail/#(article.uid)">
										<img alt="#(article.nickName)" src="/upload/avatar/#(article.avatar)" />
									</a>
								</dt>
								<dd class="pull-left">
									<a class="aw-user-name" href="/user/detail/#(article.uid)" data-id="#(article.uid)">#(article.nickName)</a>
									#if(article.is_auth==1)<i class="icon-v" title="个人认证"></i>#end
									<p>#(article.sign)</p>
								</dd>
							</dl>
						</div>
					</div>
					<!-- end 发起人 -->
					<!-- 相关问题 -->
					<div class="aw-mod aw-text-align-justify question-related-list">
						<div class="mod-head">
							<h3>热门文章</h3>
						</div>
						<div class="mod-body font-size-12">
							<ul>
								#for(articleHot : articleHot)
								<li><a href="/detail/#(articleHot.aid)">#(articleHot.title)</a></li>
								#end
							</ul>
						</div>
					</div>
					<!-- end 相关问题 -->
					<!-- 广告位 -->
					<div class="aw-mod aw-text-align-justify question-related-list">
						<div class="mod-head">
							<h3>广告位</h3>
						</div>
						<div class="mod-body font-size-12" style="margin-bottom: 10px;">
							<a href="#(advImg.skip)" target="_blank">
								<img src="#(advImg.value)" style="width: 100%;" title="#(advImg.remarks)">
							</a>
						</div>
					</div>
				</div>
				<!-- end 侧边栏 -->
			</div>
		</div>
	</div>
</div>
<!-- 内容区域end -->
#end
#define js()
<script type="text/javascript">
$(document).ready(function() {
	var map = {
		isLoading: false
		, submit_btn: $("#submit_btn")
		, submit_loading: $("#submit_loading")
	};

	$("#submit_btn").bind("click", function() {
		articleReply("/saveArticleReply", "#(article.aid)", map);
	});

	$("#replyContent").bind("keydown", function(e) {
		if ((e.ctrlKey || e.metaKey) && e.keyCode==13) {    // ctrl + 回车发送消息
			articleReply("/saveArticleReply", "#(article.id)", map);   // $("#submit_btn").trigger("click");   // 简写 $("#submit_btn").click();
		}
	});
});

function downloadVip(aid) {
    $.post("/download/userVipDownLoad",{"aid":aid},function(result) {
        if (result.errMsg == 1) {
            layer.alert("您还没有登录，请先去登录。");
            return;
        }
        if(result.errMsg == 2){
            layer.alert("您不是VIP用户，不能通过此路径下载。");
            return;
        }
        if(result.errMsg == 3){
            layer.confirm('欢迎您VIP用户，下载不会扣除您的积分,您确定要下载这个资源吗？', {
                title:"下载提示"
                ,btn: ['确定','取消'] //按钮
            }, function(){
                layer.closeAll('dialog');
                layer.open({
                    type: 2,
                    title: '资源下载页面',
                    shadeClose: true,
                    data:'vip',
                    shade: 0.8,
                    area: ['550px', '450'],
                    content: '/download/toVipDownLoadPage?aid=#(article.aid)' //iframe的url
                });
            }, function(){

            });
            return;
        }
    });
}

function download(aid){
    // 判断是否登录，显示默认使用用户已经登录
    // 判断是否下载过
    // 添加记录
    $.post("/download/userDownloadExist",{"aid":aid},function(result){
        if(result.errMsg == 1){
            layer.alert("您还没有登录，请先去登录。");
            return;
        }

        if(result.errMsg == 2){
            layer.confirm('该资您已经下载过,重复下载不会扣除您的积分,您确定要下载这个资源吗？', {
                title:"下载提示"
                ,btn: ['确定','取消'] //按钮
            }, function(){
                layer.closeAll('dialog');
                layer.open({
                    type: 2,
                    title: '资源下载页面',
                    shadeClose: true,
                    data:'vip',
                    shade: 0.8,
                    area: ['550px', '450'],
                    content: '/download/toVipDownLoadPage?aid=#(article.aid)' //iframe的url
                });
            }, function(){

            });
            return;
        }

        if(result.errMsg == 4){
            layer.confirm('该资源下载需要 <font color="red">#(article.points)</font> 积分,您确定要下载这个资源吗？', {
                title:"下载提示"
                ,btn: ['确定','取消'] //按钮
            }, function(){
                $.post("/download/userDownloadCkeck",{"aid":aid},function(results){
                    if(results.errMsg == 3){
                        layer.alert("对不起，您的积分不够，请去充值。");
                        return;
                    }
                    if(results.errMsg == 5){
                        layer.closeAll('dialog');
                        layer.open({
                            type: 2,
                            title: '资源下载页面',
                            shadeClose: true,
                            value:'vip',
                            shade: 0.8,
                            area: ['550px', '450'],
                            content: '/download/toVipDownLoadPage?aid=#(article.aid)' //iframe的url
                        });
                    }else{
                        layer.alert("对不起，系统错误，请联系管理员。");
                        return;
                    }
                });
            });
            return;
        }
    });

}
</script>
#end